package com.mask.im.business.controller;

import com.mask.im.business.annotation.AesCrypto;
import com.mask.im.business.model.dto.FriendFeedDTO;
import com.mask.im.business.model.vo.FriendFeedCommentVO;
import com.mask.im.business.model.vo.PostUpdatesVO;
import com.mask.im.business.common.model.RestResponse;
import com.mask.im.business.service.IMFriendDynamicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 好友动态管理
 *
 * @author jian
 */
@Api(tags = "好友动态管理")
@RestController
public class IMFriendDynamicController {

    @Resource
    private IMFriendDynamicService friendDynamicService;

    @ApiOperation("获取动态")
    @GetMapping("/users/dynamic/lists")
    public RestResponse<List<FriendFeedDTO>> dynamicLists() {
        return friendDynamicService.dynamicLists();
    }


    @ApiOperation("获取自己的动态")
    @GetMapping("/users/ownDynamics/lists")
    public RestResponse<List<FriendFeedDTO>> ownDynamicsLists() {
        return friendDynamicService.ownDynamicsLists();
    }


    @ApiOperation("根据动态Id获取动态信息")
    @GetMapping("/users/dynamic")
    public RestResponse<FriendFeedDTO> dynamicById(@RequestParam("friendFeedId") Integer friendFeedId) {
        return friendDynamicService.dynamicById(friendFeedId);
    }

    @ApiOperation("发布动态")
    @PostMapping("/users/friendFeed")
    @AesCrypto
    public RestResponse<String> postUpdates(@RequestBody PostUpdatesVO postUpdatesVO) {
        return friendDynamicService.PostUpdates(postUpdatesVO);
    }

    @ApiOperation("对动态进行评论")
    @PostMapping("/users/friendFeed/comment")
    @AesCrypto
    public RestResponse<String> friendFeedComment(@RequestBody FriendFeedCommentVO friendFeedCommentVO) {
        return friendDynamicService.friendFeedComment(friendFeedCommentVO);
    }

    @ApiOperation("动态点亮")
    @PutMapping("/users/friendFeed/lit/{friendFeedId}")
    public RestResponse<String> friendFeedLit(@PathVariable Integer friendFeedId) {
        return friendDynamicService.friendFeedLit(friendFeedId);
    }

    @ApiOperation("删除自己发布的动态")
    @DeleteMapping("users/delete/myselfDynamic/{id}")
    public RestResponse<String> delMyselfDynamic(@PathVariable Integer id) {
        return friendDynamicService.delMyselfDynamic(id);
    }
}

